{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 线性模型和梯度下降\n",
    "这是神经网络的第一课，我们会学习一个非常简单的模型，线性回归，同时也会学习一个优化算法-梯度下降法，对这个模型进行优化。线性回归是监督学习里面一个非常简单的模型，同时梯度下降也是深度学习中应用最广的优化算法，我们将从这里开始我们的深度学习之旅"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 一元线性回归\n",
    "一元线性模型非常简单，假设我们有变量 $x_i$ 和目标 $y_i$，每个 i 对应于一个数据点，希望建立一个模型\n",
    "\n",
    "$$\n",
    "\\hat{y}_i = w x_i + b\n",
    "$$\n",
    "\n",
    "$\\hat{y}_i$ 是我们预测的结果，希望通过 $\\hat{y}_i$ 来拟合目标 $y_i$，通俗来讲就是找到这个函数拟合 $y_i$ 使得误差最小，即最小化\n",
    "\n",
    "$$\n",
    "\\frac{1}{n} \\sum_{i=1}^n(\\hat{y}_i - y_i)^2\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "那么如何最小化这个误差呢？\n",
    "\n",
    "这里需要用到**梯度下降**，这是我们接触到的第一个优化算法，非常简单，但是却非常强大，在深度学习中被大量使用，所以让我们从简单的例子出发了解梯度下降法的原理"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 梯度下降法\n",
    "在梯度下降法中，我们首先要明确梯度的概念，随后我们再了解如何使用梯度进行下降。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 梯度\n",
    "梯度在数学上就是导数，如果是一个多元函数，那么梯度就是偏导数。比如一个函数f(x, y)，那么 f 的梯度就是 \n",
    "\n",
    "$$\n",
    "(\\frac{\\partial f}{\\partial x},\\ \\frac{\\partial f}{\\partial y})\n",
    "$$\n",
    "\n",
    "可以称为 grad f(x, y) 或者 $\\nabla f(x, y)$。具体某一点 $(x_0,\\ y_0)$ 的梯度就是 $\\nabla f(x_0,\\ y_0)$。\n",
    "\n",
    "下面这个图片是 $f(x) = x^2$ 这个函数在 x=1 处的梯度\n",
    "\n",
    "![](https://ws3.sinaimg.cn/large/006tNc79ly1fmarbuh2j3j30ba0b80sy.jpg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "梯度有什么意义呢？从几何意义来讲，一个点的梯度值是这个函数变化最快的地方，具体来说，对于函数 f(x, y)，在点 $(x_0, y_0)$ 处，沿着梯度 $\\nabla f(x_0,\\ y_0)$ 的方向，函数增加最快，也就是说沿着梯度的方向，我们能够更快地找到函数的极大值点，或者反过来沿着梯度的反方向，我们能够更快地找到函数的最小值点。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 梯度下降法\n",
    "有了对梯度的理解，我们就能了解梯度下降发的原理了。上面我们需要最小化这个误差，也就是需要找到这个误差的最小值点，那么沿着梯度的反方向我们就能够找到这个最小值点。\n",
    "\n",
    "我们可以来看一个直观的解释。比如我们在一座大山上的某处位置，由于我们不知道怎么下山，于是决定走一步算一步，也就是在每走到一个位置的时候，求解当前位置的梯度，沿着梯度的负方向，也就是当前最陡峭的位置向下走一步，然后继续求解当前位置梯度，向这一步所在位置沿着最陡峭最易下山的位置走一步。这样一步步的走下去，一直走到觉得我们已经到了山脚。当然这样走下去，有可能我们不能走到山脚，而是到了某一个局部的山峰低处。\n",
    "\n",
    "类比我们的问题，就是沿着梯度的反方向，我们不断改变 w 和 b 的值，最终找到一组最好的 w 和 b 使得误差最小。\n",
    "\n",
    "在更新的时候，我们需要决定每次更新的幅度，比如在下山的例子中，我们需要每次往下走的那一步的长度，这个长度称为学习率，用 $\\eta$ 表示，这个学习率非常重要，不同的学习率都会导致不同的结果，学习率太小会导致下降非常缓慢，学习率太大又会导致跳动非常明显，可以看看下面的例子\n",
    "\n",
    "![](https://ws2.sinaimg.cn/large/006tNc79ly1fmgn23lnzjg30980gogso.gif)\n",
    "\n",
    "可以看到上面的学习率较为合适，而下面的学习率太大，就会导致不断跳动\n",
    "\n",
    "最后我们的更新公式就是\n",
    "\n",
    "$$\n",
    "w := w - \\eta \\frac{\\partial f(w,\\ b)}{\\partial w} \\\\\n",
    "b := b - \\eta \\frac{\\partial f(w,\\ b)}{\\partial b}\n",
    "$$\n",
    "\n",
    "通过不断地迭代更新，最终我们能够找到一组最优的 w 和 b，这就是梯度下降法的原理。\n",
    "\n",
    "最后可以通过这张图形象地说明一下这个方法\n",
    "\n",
    "![](https://ws3.sinaimg.cn/large/006tNc79ly1fmarxsltfqj30gx091gn4.jpg)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "上面是原理部分，下面通过一个例子来进一步学习线性模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<torch._C.Generator at 0x112959630>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import torch\n",
    "import numpy as np\n",
    "from torch.autograd import Variable\n",
    "\n",
    "torch.manual_seed(2017)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 读入数据 x 和 y\n",
    "x_train = np.array([[3.3], [4.4], [5.5], [6.71], [6.93], [4.168],\n",
    "                    [9.779], [6.182], [7.59], [2.167], [7.042],\n",
    "                    [10.791], [5.313], [7.997], [3.1]], dtype=np.float32)\n",
    "\n",
    "y_train = np.array([[1.7], [2.76], [2.09], [3.19], [1.694], [1.573],\n",
    "                    [3.366], [2.596], [2.53], [1.221], [2.827],\n",
    "                    [3.465], [1.65], [2.904], [1.3]], dtype=np.float32)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x11565e588>]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAD7VJREFUeJzt3XGIpPV9x/HPZ88DnRhqyy3R3rk7/UNSolhPBmMVipgK\nxkrtH/5hmZoQCktEWi1CabNgyR9b8keRNh54DDGN0sESVKyItpXkIAr1wt71cnp3QoTermcvvdXg\nndeRtJf79o/nud462c08szuzzzO/5/2C4Znnt7+b+TLMfu63z3yfZxwRAgCkZarsAgAAo0e4A0CC\nCHcASBDhDgAJItwBIEGEOwAkiHAHgAQR7gCQIMIdABJ0SVlPvGPHjmg2m2U9PQBMpAMHDrwfEdOD\n5pUW7s1mU4uLi2U9PQBMJNtLReZxWAYAEkS4A0CCBoa77Utt/9D2j2wfsf31NebcZvu07UP57dHx\nlAsAKKLIMfefSbo9Is7a3i7pdduvRMQbffNei4i7R18iAGBYA8M9sgu+n813t+c3LgIPABVW6Ji7\n7W22D0k6JenViNi/xrRbbB+2/Yrta9d5nDnbi7YXV1ZWNlE2AEyebldqNqWpqWzb7Y7vuQqFe0T8\nPCJukLRL0k22r+ubclDSTERcL+lxSS+s8zidiGhFRGt6emCbJgAko9uV5uakpSUpItvOzY0v4Ifq\nlomIDyXtk3Rn3/iZiDib339Z0nbbO0ZWJQBMuPl5qdf75Fivl42PQ5FumWnbV+T3L5N0h6S3++Zc\nadv5/Zvyx/1g9OUCwGRaXh5ufLOKdMtcJekp29uUhfZ3I+Il21+VpIjYK+leSQ/YPifpY0n3Bd+8\nDQD/b2YmOxSz1vg4FOmWOSxp9xrje1fd3yNpz2hLA4B0LCxkx9hXH5ppNLLxceAMVQDYAu221OlI\ns7OSnW07nWx8HEq7cBgA1E27Pb4w78fKHQASRLgD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4S+8Z5WFPaTflfQfEbESEf8r6XlJ\nt5RcU9X8l+2rJCnfniq5nk2rZLjbtrJjp8ci4rGy66mKiPjLiNgVEU1lH4h9PyJYgUmKiJ9Ietf2\nZ/OhL0g6WmJJVbIs6Wbbjfx36wviw+Z+L0r6cn7/y5L+qcRaRqKS4a5shXq/spXpofx2V9lFofL+\nRFLX9mFJN0j665LrqYT8r5lnJR2U9Kay3/vkzsgsyvYzkv5N0mdtn7D9x5K+IekO2z9W9pfON8qs\ncRQ4QxUAElTVlTsAYBMIdwBIEOEOAAki3AEgQYQ7ACSIcAeABBHuAJAgwh0AEvR/pcuwDbjnoq8A\nAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1146f2438>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 画出图像\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "plt.plot(x_train, y_train, 'bo')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 转换成 Tensor\n",
    "x_train = torch.from_numpy(x_train)\n",
    "y_train = torch.from_numpy(y_train)\n",
    "\n",
    "# 定义参数 w 和 b\n",
    "w = Variable(torch.randn(1), requires_grad=True) # 随机初始化\n",
    "b = Variable(torch.zeros(1), requires_grad=True) # 使用 0 进行初始化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 构建线性回归模型\n",
    "x_train = Variable(x_train)\n",
    "y_train = Variable(y_train)\n",
    "\n",
    "def linear_model(x):\n",
    "    return x * w + b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_ = linear_model(x_train)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "经过上面的步骤我们就定义好了模型，在进行参数更新之前，我们可以先看看模型的输出结果长什么样"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x11577da58>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFuVJREFUeJzt3X9wVeWdx/HPNxjFKONayVIUk+CMZYsgCBcX16mlgsoW\nu8rYdspkK5ltG1uKazsdd9zljzKVbDtOF3ans2NN1YVK6taiax3XqT+Q0f5wqoFFi7AFBxMKoiC4\nFAkUSL77x7lBEpPc3/ec+9z3a+bOvffkcs83R+8nz33Oc57H3F0AgMpXE3cBAIDiINABIBAEOgAE\ngkAHgEAQ6AAQCAIdAAJBoANAIAh0AAgEgQ4AgTijnDsbO3asNzU1lXOXAFDxNm7c+K6712d6XVkD\nvampSZ2dneXcJQBUPDPrzuZ1GbtczOxiM9tgZlvN7HUzuyO9fbmZ7TGzzenbpwstGgCQv2xa6Ccl\nfcvdN5nZGEkbzezZ9M9Wufv3S1ceACBbGQPd3fdK2pt+fNjMtkm6qNSFAQByk1Mfupk1SbpC0m8l\nXS3pdjO7VVKnolb8e7kWcOLECe3evVvHjh3L9Z9iGKNHj9aECRNUW1sbdykAysiynQ/dzM6V9IKk\nNnd/zMzGSXpXkku6W9J4d/+7If5dq6RWSWpoaJjZ3T2wb//NN9/UmDFjdMEFF8jMCvplILm7Dhw4\noMOHD2vixIlxlwOgCMxso7unMr0uq3HoZlYr6VFJHe7+mCS5+zvu3uvufZJ+JOnKof6tu7e7e8rd\nU/X1Hx51c+zYMcK8iMxMF1xwAd94gKTo6JCamqSamui+o6Nku8rY5WJR0j4gaZu7rzxt+/h0/7ok\nLZS0Jd8iCPPi4ngCCdHRIbW2Sj090fPu7ui5JDU3F3132bTQr5b0RUnXDhqieI+Z/c7MXpP0KUnf\nLHp1AFDJli37IMz79fRE20sgm1Euv5I0VJPvqeKXU5laWlp044036rOf/WzcpQBIkl27ctteoIqb\ny6XU3VHurr6+vuK+KYDq1NCQ2/YCVVSg93dHdXdL7h90RxUa6l1dXZo0aZJuvfVWTZkyRQ899JCu\nuuoqzZgxQ5/73Of0/vvvS5K+853vaNasWZoyZYpaW1uV7QghAFWqrU2qqxu4ra4u2l4CFRXopeyO\n2rFjh5YsWaIXXnhBDzzwgJ577jlt2rRJqVRKK1dG54KXLl2qV155RVu2bNHRo0f15JNPFr5jAOFq\nbpba26XGRsksum9vL8kJUanMk3MVqpTdUY2NjZo9e7aefPJJbd26VVdffbUk6fjx47rqqqskSRs2\nbNA999yjnp4eHTx4UJdddpk+85nPFL5zAOFqbi5ZgA9WUYHe0BB1swy1vVDnnHOOpKgP/brrrtPD\nDz884OfHjh3TkiVL1NnZqYsvvljLly9nrDeARKmoLpdydEfNnj1bv/71r/XGG29Iko4cOaLt27ef\nCu+xY8fq/fff17p164q3UwAogopqofd/a1m2LOpmaWiIwryY32bq6+u1evVqLVq0SH/6058kSStW\nrNDHPvYxfeUrX9GUKVP00Y9+VLNmzSreTgGgCLKey6UYUqmUD17gYtu2bfr4xz9ethqqBccVCEdR\n53IBACQfgQ4AgSDQASAQBDoABIJAB4BAEOgAEAgCPQerV6/WW2+9der5l7/8ZW3durXg9+3q6tJP\nfvKTnP9dS0sLFzgBOKXyAr2MyzkNNjjQ77//fk2ePLng98030AHgdJUV6CWaP3ft2rW68sorNX36\ndN12223q7e1VS0uLpkyZoqlTp2rVqlVat26dOjs71dzcrOnTp+vo0aOaM2eO+i+UOvfcc3XnnXfq\nsssu07x58/Tyyy9rzpw5uuSSS/TEE09IioL7E5/4hGbMmKEZM2boN7/5jSTprrvu0i9/+UtNnz5d\nq1atUm9vr+68807NmjVLl19+ue677z5J0TwzS5cu1aRJkzRv3jzt27evoN8bCFKMjb7YuXvZbjNn\nzvTBtm7d+qFtw2psdI+ifOCtsTH79xhi/zfeeKMfP37c3d2/9rWv+fLly33evHmnXvPee++5u/sn\nP/lJf+WVV05tP/25JH/qqafc3f3mm2/26667zo8fP+6bN2/2adOmubv7kSNH/OjRo+7uvn37du8/\nHhs2bPAFCxacet/77rvP7777bnd3P3bsmM+cOdN37tzpjz76qM+bN89Pnjzpe/bs8fPOO89/9rOf\nDft7AVVn7Vr3urqB+VBXF22vYJI6PYuMrai5XEoxf+769eu1cePGU3OzHD16VPPnz9fOnTt1++23\na8GCBbr++uszvs+ZZ56p+fPnS5KmTp2qs846S7W1tZo6daq6urokSSdOnNDSpUu1efNmjRo1Stu3\nbx/yvZ555hm99tprp/rHDx06pB07dujFF1/UokWLNGrUKF144YW69tpr8/69gSCNtGhCmaawjVNl\nBXoJ5s91dy1evFjf/e53B2xva2vT008/rR/+8Id65JFH9OCDD474PrW1tTKLll6tqanRWWedderx\nyZMnJUmrVq3SuHHj9Oqrr6qvr0+jR48etqYf/OAHuuGGGwZsf+oplnEFRlTmNTyTprL60Eswf+7c\nuXO1bt26U/3RBw8eVHd3t/r6+nTLLbdoxYoV2rRpkyRpzJgxOnz4cN77OnTokMaPH6+amho99NBD\n6u3tHfJ9b7jhBt177706ceKEJGn79u06cuSIrrnmGv30pz9Vb2+v9u7dqw0bNuRdCxCkMq/hmTSV\n1UIvwfy5kydP1ooVK3T99derr69PtbW1WrlypRYuXHhqsej+1ntLS4u++tWv6uyzz9ZLL72U876W\nLFmiW265RT/+8Y81f/78U4tqXH755Ro1apSmTZumlpYW3XHHHerq6tKMGTPk7qqvr9fjjz+uhQsX\n6vnnn9fkyZPV0NBwaiUlAGltbdFAidO7XUq4hmfSMH1uoDiuqFodHaVdNCEG2U6fW1ktdADIpIxr\neCZNZfWhAwCGlYhAL2e3TzXgeALVKfZAHz16tA4cOEAIFYm768CBA8MOiQQQrtj70CdMmKDdu3dr\n//79cZcSjNGjR2vChAlxlwGgzGI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MztP0jWSHpAkdz/u7v8X\nb1WJcYaks83sDEl1kt6KuZ7YuPuLkg4O2nyTpDXpx2sk3VzWokokMYF+OjNrknSFpN/GW0li/Kuk\nf5BUppVUK8ZESfsl/Ue6O+p+Mzsn7qLi5u57JH1f0i5JeyUdcvdn4q0qcca5+97047cljYuzmGJJ\nXKCb2bmSHpX0DXf/Y9z1xM3MbpS0z903xl1LAp0haYake939CklHFMhX50Kk+4NvUvQH70JJ55jZ\n38ZbVXJ5NNQviOF+iQp0M6tVFOYd7v5Y3PUkxNWS/sbMuhRNgHatma2Nt6TE2C1pt7v3f5Nbpyjg\nq908SW+6+353PyHpMUl/FXNNSfOOmY2XpPT9vpjrKYrEBLqZmaK+0G3uvjLuepLC3f/R3Se4e5Oi\nE1vPuzutLUnu/rakP5jZpPSmuZK2xlhSUuySNNvM6tKfq7niZPFgT0hanH68WNLPY6ylaBIT6Ipa\nol9U1ALdnL59Ou6ikHi3S+ows9ckTZf0zzHXE7v0N5Z1kjZJ+p2iz3lwV0Vmy8welvSSpElmttvM\nviTpe5KuM7Mdir7RfC/OGouFK0UBIBBJaqEDAApAoANAIAh0AAgEgQ4AgSDQASAQBDoABIJAB4BA\nEOgAEIj/B0G15NO6D6dTAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1155f3be0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x_train.data.numpy(), y_train.data.numpy(), 'bo', label='real')\n",
    "plt.plot(x_train.data.numpy(), y_.data.numpy(), 'ro', label='estimated')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**思考：红色的点表示预测值，似乎排列成一条直线，请思考一下这些点是否在一条直线上？**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这个时候需要计算我们的误差函数，也就是\n",
    "\n",
    "$$\n",
    "\\frac{1}{n} \\sum_{i=1}^n(\\hat{y}_i - y_i)^2\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# 计算误差\n",
    "def get_loss(y_, y):\n",
    "    return torch.mean((y_ - y_train) ** 2)\n",
    "\n",
    "loss = get_loss(y_, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Variable containing:\n",
      " 153.3520\n",
      "[torch.FloatTensor of size 1]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 打印一下看看 loss 的大小\n",
    "print(loss)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "定义好了误差函数，接下来我们需要计算 w 和 b 的梯度了，这时得益于 PyTorch 的自动求导，我们不需要手动去算梯度，有兴趣的同学可以手动计算一下，w 和 b 的梯度分别是\n",
    "\n",
    "$$\n",
    "\\frac{\\partial}{\\partial w} = \\frac{2}{n} \\sum_{i=1}^n x_i(w x_i + b - y_i) \\\\\n",
    "\\frac{\\partial}{\\partial b} = \\frac{2}{n} \\sum_{i=1}^n (w x_i + b - y_i)\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 自动求导\n",
    "loss.backward()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Variable containing:\n",
      " 161.0043\n",
      "[torch.FloatTensor of size 1]\n",
      "\n",
      "Variable containing:\n",
      " 22.8730\n",
      "[torch.FloatTensor of size 1]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 查看 w 和 b 的梯度\n",
    "print(w.grad)\n",
    "print(b.grad)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# 更新一次参数\n",
    "w.data = w.data - 1e-2 * w.grad.data\n",
    "b.data = b.data - 1e-2 * b.grad.data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "更新完成参数之后，我们再一次看看模型输出的结果"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x11588b358>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD8CAYAAABXe05zAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFfJJREFUeJzt3X9w3HWdx/HXO2mgtOXwbDMIliR15uxZUhrKlinHiT1o\nsVJUGM4ZO1Gpdxi1lqung4PTP47DIo5z08rgDJIrikBAj6Ie0+E8BKr4gwO2NXDYSuuVpAbQxlYr\nbVraJu/7YzehDZvud5P97vf72X0+ZjLJbje77+5OX/1839/P5/M1dxcAIBx1SRcAACgNwQ0AgSG4\nASAwBDcABIbgBoDAENwAEBiCGwACQ3ADQGAIbgAIzKQ4nnTGjBne0tISx1MDQFXasmXLH9y9Mcpj\nYwnulpYWZbPZOJ4aAKqSmfVGfSytEgAITNHgNrPZZtZ93NefzeyzlSgOAPBmRVsl7v6ipDZJMrN6\nSS9L+n7MdQEAxlBqj/sySf/n7pF7McOOHj2qvr4+HT58uNRfxRgmT56smTNnqqGhIelSAFRQqcH9\nYUkPFPoDM+uQ1CFJTU1Nb/rzvr4+nX766WppaZGZlVonRnF37d27V319fZo1a1bS5QCooMgnJ83s\nFEkfkPRgoT939053z7h7prHxzTNaDh8+rOnTpxPaZWJmmj59OkcwQBp0dUktLVJdXe57V1esL1fK\niPt9kra6++/H+2KEdnnxfgIp0NUldXRIAwO52729uduS1N4ey0uWMh1wucZokwBAzVqz5o3QHjYw\nkLs/JpGC28ymSloi6XuxVZJyK1as0MaNG5MuA0Da7N5d2v1lECm43f2gu0939/2xVTJKnC0jd9fQ\n0FD5nhBA7SowGeOk95dBKldODreMensl9zdaRhMJ756eHs2ePVsf+9jH1NraqnvvvVcXXXSR5s+f\nrw996EM6cOCAJOnmm2/WggUL1Nraqo6ODrl7mf5WAKrSLbdIU6aceN+UKbn7Y5LK4I6rZbRz506t\nXLlSP/nJT3TXXXfpscce09atW5XJZLRu3TpJ0qpVq/Tss8/qhRde0KFDh7Rp06aJvSiA6tbeLnV2\nSs3Nklnue2dnbCcmpZg2mZqouFpGzc3NWrhwoTZt2qRt27bp4osvliQdOXJEF110kSRp8+bN+upX\nv6qBgQHt27dP5557rt7//vdP7IUBVLf29liDerRUBndTU649Uuj+iZg6daqkXI97yZIleuCBEyfJ\nHD58WCtXrlQ2m9U555yjm266iXnSAFInla2SuFtGCxcu1M9//nP95je/kSQdPHhQO3bsGAnpGTNm\n6MCBA8wiAZBKqRxxDx9xrFmTa480NeVCu1xHIo2Njbr77ru1fPlyvf7665KktWvX6p3vfKc+8YlP\nqLW1VW9729u0YMGC8rwgAJSRxTFrIpPJ+OgLKWzfvl3vete7yv5atY73FagOZrbF3TNRHpvKVgkA\nYGwENwAEhuAGgMAQ3AAQGIIbAAJDcANAYAjuAu6++2698sorI7evu+46bdu2bcLP29PTo/vvv7/k\n32NLWQDHS29wV/hSQMcbHdwbNmzQnDlzJvy84w1uADheOoM7jn1dJd1333268MIL1dbWpk9+8pMa\nHBzUihUr1Nraqrlz52r9+vXauHGjstms2tvb1dbWpkOHDmnRokUaXlA0bdo03XDDDTr33HO1ePFi\nPfPMM1q0aJHe8Y536OGHH5aUC+h3v/vdmj9/vubPn69f/OIXkqQbb7xRP/3pT9XW1qb169drcHBQ\nN9xwgxYsWKDzzjtPd955p6TcXiqrVq3S7NmztXjxYu3Zs2dCf28AVcbdy/51wQUX+Gjbtm17031j\nam52z0X2iV/NzdGfo8DrX3nllX7kyBF3d//0pz/tN910ky9evHjkMX/84x/d3f0973mPP/vssyP3\nH39bkj/yyCPu7n7VVVf5kiVL/MiRI97d3e3z5s1zd/eDBw/6oUOH3N19x44dPvx+bN682ZctWzby\nvHfeead/6Utfcnf3w4cP+wUXXOC7du3yhx56yBcvXuzHjh3zl19+2c844wx/8MEHx/x7AQifpKxH\nzNhU7lUSx76ujz/+uLZs2TKy/8ihQ4e0dOlS7dq1S9dff72WLVumyy+/vOjznHLKKVq6dKkkae7c\nuTr11FPV0NCguXPnqqenR5J09OhRrVq1St3d3aqvr9eOHTsKPtejjz6q559/fqR/vX//fu3cuVNP\nPvmkli9frvr6ep199tm69NJLx/33BlB90tkqieFSQO6ua6+9Vt3d3eru7taLL76o2267Tc8995wW\nLVqkb3zjG7ruuuuKPk9DQ8PI1dXr6up06qmnjvx87NgxSdL69et15pln6rnnnlM2m9WRI0fGrOn2\n228fqemll16K9J8HUPMSPAeWBukM7hj2db3sssu0cePGkX7xvn371Nvbq6GhIV1zzTVau3attm7d\nKkk6/fTT9dprr437tfbv36+zzjpLdXV1uvfeezU4OFjwed/73vfqjjvu0NGjRyVJO3bs0MGDB3XJ\nJZfou9/9rgYHB/Xqq69q8+bN464FqDoxnQMLSTpbJTHs6zpnzhytXbtWl19+uYaGhtTQ0KB169bp\n6quvHrlw8K233iopN/3uU5/6lE477TQ99dRTJb/WypUrdc011+iee+7R0qVLRy7gcN5556m+vl7z\n5s3TihUrtHr1avX09Gj+/PlydzU2NuoHP/iBrr76aj3xxBOaM2eOmpqaRq7OA0Anv7ZhBa9CkyS2\ndQ0c7ytqTl1dbqQ9mpmUH4SFiG1dAVSvGM6BhYbgBhCWuK9tGICKBnccbZlaxvuJmtTeLnV2Ss3N\nufZIc3Pudo30t6WIJyfN7C2SNkhqleSS/sHdSzprN3nyZO3du1fTp08fmU6H8XN37d27V5MnT066\nFKDy2ttrKqhHizqr5DZJP3T3vzezUyRNKfYLo82cOVN9fX3q7+8v9VcxhsmTJ2vmzJlJlwG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LCk2SNF/SHe5+vqSDqpJD3onI92s/qNx/bGdLmmpmH0m2qvTy3BS6qphGV/Hg\nNrMG5UK7y92/V+nXT7GLJX3AzHokfUfSpWZ2X7IlpUafpD53Hz4626hckNe6xZJecvd+dz8q6XuS\n/ibhmtLm92Z2liTlv+9JuJ6yqPSsElOuT7nd3ddV8rXTzt2/6O4z3b1FuRNMT7g7oydJ7v47Sb81\ns9n5uy6TtC3BktJit6SFZjYl/2/rMnHSdrSHJV2b//laSf+ZYC1lU+kR98WSPqrcaLI7/3VFhWtA\nmK6X1GVmz0tqk/TlhOtJXP4IZKOkrZL+V7l/z1W5UjCK/E6mT0mabWZ9ZvaPkr4iaYmZ7VTuCOUr\nSdZYLqycBIDAsHISAAJDcANAYAhuAAgMwQ0AgSG4ASAwBDcABIbgBoDAENwAEJj/B4eTq//LFqBm\nAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1156dc6d8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "y_ = linear_model(x_train)\n",
    "plt.plot(x_train.data.numpy(), y_train.data.numpy(), 'bo', label='real')\n",
    "plt.plot(x_train.data.numpy(), y_.data.numpy(), 'ro', label='estimated')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "从上面的例子可以看到，更新之后红色的线跑到了蓝色的线下面，没有特别好的拟合蓝色的真实值，所以我们需要在进行几次更新"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch: 0, loss: 3.1357719898223877\n",
      "epoch: 1, loss: 0.3550889194011688\n",
      "epoch: 2, loss: 0.30295443534851074\n",
      "epoch: 3, loss: 0.30131956934928894\n",
      "epoch: 4, loss: 0.3006229102611542\n",
      "epoch: 5, loss: 0.29994693398475647\n",
      "epoch: 6, loss: 0.299274742603302\n",
      "epoch: 7, loss: 0.2986060082912445\n",
      "epoch: 8, loss: 0.2979407012462616\n",
      "epoch: 9, loss: 0.29727882146835327\n"
     ]
    }
   ],
   "source": [
    "for e in range(10): # 进行 10 次更新\n",
    "    y_ = linear_model(x_train)\n",
    "    loss = get_loss(y_, y_train)\n",
    "    \n",
    "    w.grad.zero_() # 记得归零梯度\n",
    "    b.grad.zero_() # 记得归零梯度\n",
    "    loss.backward()\n",
    "    \n",
    "    w.data = w.data - 1e-2 * w.grad.data # 更新 w\n",
    "    b.data = b.data - 1e-2 * b.grad.data # 更新 b \n",
    "    print('epoch: {}, loss: {}'.format(e, loss.data[0]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x11598e0f0>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGcFJREFUeJzt3X+QVfWZ5/H3B9IRf23YkS5jhO42VZYbQERsGdBKQiko\nUTPGMqnS7Yk6tYYg4prdrFPuWJVxjEymUls6/tgSGc06KnFSwYxrUbiTxDBRY1QapmUUDFKmwTZM\n6GCCgjD86Gf/uLfbpu3mntt97z3nnvt5Vd3qe889nPNwq/vpbz/n+32OIgIzM8uXcWkHYGZmlefk\nbmaWQ07uZmY55ORuZpZDTu5mZjnk5G5mlkNO7mZmOeTkbmaWQ07uZmY59LG0Tjxp0qRoa2tL6/Rm\nZnVp/fr1v4uI5lL7pZbc29ra6OzsTOv0ZmZ1SdK2JPu5LGNmlkNO7mZmOeTkbmaWQ6nV3Idz8OBB\nenp62L9/f9qh5MaECROYPHkyTU1NaYdiZjWUqeTe09PDiSeeSFtbG5LSDqfuRQS7du2ip6eH0047\nLe1wzKyGMl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ZCT+xg88sgj/OY3vxl4ff3117Np06YxH7e7u5vvf//7Zf87txs2s371ndxreMuq\n4QxN7g899BBTp04d83FHm9zNzPrVb3KvVs9f4PHHH2f27NnMnDmTr3/96xw+fJjrrruO6dOnc+aZ\nZ3L33XezatUqOjs76ejoYObMmezbt4958+bRvzDrhBNO4JZbbmHatGnMnz+fV155hXnz5vHpT3+a\np59+Gigk8c9+9rPMmjWLWbNm8eKLLwJw66238vzzzzNz5kzuvvtuDh8+zC233MK5557LjBkzePDB\nB4FC75ulS5dyxhlnMH/+fHbu3Dnm/7uZ5UREpPI455xzYqhNmzZ9ZNuIWlsjCmn9yEdra/JjDGPT\npk1x2WWXxYEDByIi4oYbbojbb7895s+fP7DP73//+4iI+PznPx/r1q0b2D74NRBr1qyJiIgvfelL\nsWDBgjhw4EB0dXXFWWedFRERe/fujX379kVExJYtW6L/M1m7dm1ceumlA8d98MEH49vf/nZEROzf\nvz/OOeeceOutt+LJJ5+M+fPnx6FDh+Kdd96JT3ziE/HDH/5w2P+TmeUD0BkJcmzmbpCdWJV6/j77\n7LOsX79+oF/Mvn37WLhwIW+99RY33XQTl156KRdddFHJ43z84x9n4cKFAJx55pkcc8wxNDU1ceaZ\nZ9Ld3Q3AwYMHWbp0KV1dXYwfP54tW7YMe6wf//jHbNy4caCevnv3bt58802ee+45rr76asaPH8+n\nPvUpLrjggjH9380sP+q3LFOlW1ZFBNdeey1dXV10dXXxq1/9invuuYdXX32VefPmsXz5cq6//vqS\nx2lqakISAOPGjeOYY44ZeH7o0CEA7r77bk4++WReffVVOjs7OXDgwIgx3XfffQMx/frXv070C8as\n4aV8XS5N9Zvcq9Tz98ILL2TVqlUD9et3332Xbdu20dfXx5VXXsmdd97Jhg0bADjxxBN5//33R32u\n3bt3c8oppzBu3Dgee+wxDh8+POxxL774Yh544AEOHjwIwJYtW9i7dy+f+9zn+MEPfsDhw4fZsWMH\na9euHXUsZrlTxety9aB+yzL9vX1vu61QimlpKST2Mfb8nTp1KnfeeSc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},
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "y_ = linear_model(x_train)\n",
    "plt.plot(x_train.data.numpy(), y_train.data.numpy(), 'bo', label='real')\n",
    "plt.plot(x_train.data.numpy(), y_.data.numpy(), 'ro', label='estimated')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "经过 10 次更新，我们发现红色的预测结果已经比较好的拟合了蓝色的真实值。\n",
    "\n",
    "现在你已经学会了你的第一个机器学习模型了，再接再厉，完成下面的小练习。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**小练习：**\n",
    "\n",
    "重启 notebook 运行上面的线性回归模型，但是改变训练次数以及不同的学习率进行尝试得到不同的结果"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 多项式回归模型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "下面我们更进一步，讲一讲多项式回归。什么是多项式回归呢？非常简单，根据上面的线性回归模型\n",
    "\n",
    "$$\n",
    "\\hat{y} = w x + b\n",
    "$$\n",
    "\n",
    "这里是关于 x 的一个一次多项式，这个模型比较简单，没有办法拟合比较复杂的模型，所以我们可以使用更高次的模型，比如\n",
    "\n",
    "$$\n",
    "\\hat{y} = w_0 + w_1 x + w_2 x^2 + w_3 x^3 + \\cdots\n",
    "$$\n",
    "\n",
    "这样就能够拟合更加复杂的模型，这就是多项式模型，这里使用了 x 的更高次，同理还有多元回归模型，形式也是一样的，只是出了使用 x，还是更多的变量，比如 y、z 等等，同时他们的 loss 函数和简单的线性回归模型是一致的。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "首先我们可以先定义一个需要拟合的目标函数，这个函数是个三次的多项式"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "y = 0.90 + 0.50 * x + 3.00 * x^2 + 2.40 * x^3\n"
     ]
    }
   ],
   "source": [
    "# 定义一个多变量函数\n",
    "\n",
    "w_target = np.array([0.5, 3, 2.4]) # 定义参数\n",
    "b_target = np.array([0.9]) # 定义参数\n",
    "\n",
    "f_des = 'y = {:.2f} + {:.2f} * x + {:.2f} * x^2 + {:.2f} * x^3'.format(\n",
    "    b_target[0], w_target[0], w_target[1], w_target[2]) # 打印出函数的式子\n",
    "\n",
    "print(f_des)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们可以先画出这个多项式的图像"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x1158f5e48>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8lOW5//HPlQVCIBCWyBaWIJssIhA2tWorqLValxZw\n17pgrbbazbr0h7XVc7SLPe05p6fFFZUKFnePtiLVWheEsMgStsgetrAmkH3m+v2RwYOWNTPJM5P5\nvl8vXjPzzDNzX0+Ab+65537ux9wdERFp+lKCLkBERBqHAl9EJEko8EVEkoQCX0QkSSjwRUSShAJf\nRCRJKPBFRJLEMQe+mT1hZtvNbOlB29qZ2SwzWx25bXvQc3ebWZGZrTSzc2NduIiIHJ/j6eE/BZz3\nhW13AbPdvQ8wO/IYMxsAXAYMjLzmD2aWGnW1IiJSb2nHuqO7v2dmPb+w+SLgrMj9qcC7wE8i26e7\nexWw1syKgJHAR0dqo0OHDt6z5xebEBGRI5k/f/4Od8852n7HHPiH0dHdt0TubwU6Ru53BeYctN+m\nyLYj6tmzJwUF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ywLmAxcn2t+L1S013NLd95lZOvA+cLu7z2mI9ppUD/9A2Ee0\n5PNX4Uoo7v6Wu9dGHs6hbonphOTuy919ZdB11NNIoMjd17h7NTCduiu6JRx3fw/YFXQdseDuW9x9\nQeR+GbCcw1xkKZ55nX2Rh+mRPw2WW00q8AHM7EEz2whcCUwOup4YuR54M+giktQxX71NgmFmPYGh\nwMfBVlI/ZpZqZouA7cAsd2+w40i4wDezt81s6SH+XATg7ve6ezdgGnBbsNUe2dGOJbLPvdQtMT0t\nuEqP7liORSTWzKwV8AJwxxc+4ScMdw+5+ynUfYofaWYNNtzWIOvhN6TDXYHrEKYBbwD3NWA5UTna\nsZjZdcAFwNke51+2HMffS6LR1dviVGTM+wVgmru/GHQ90XL3PWb2DnAe0CBfrCdcD/9IzKzPQQ8v\nAlYEVUu0zOw84E7g6+5eHnQ9SWwe0MfM8sysGXAZdVd0kwBFvux8HFju7o8EXU99mVnOgRl4ZtaC\nuskBDZZbTW2WzgtAP+pmhKwHvu3uCdkbM7MioDmwM7JpTgLPOLoE+E8gB9gDLHL3c4Ot6tiZ2fnA\nfwCpwBORi/skHDN7DjiLulUZtwH3ufvjgRZVT2Z2OvBPYAl1/98B7nH3N4Kr6viZ2cnAVOr+baUA\nz7v7zxusvaYU+CIicnhNakhHREQOT4EvIpIkFPgiIklCgS8ikiQU+CIiSUKBLyKSJBT4IiJJQoEv\nIpIk/j8hjlpJApitKgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1158f5dd8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 画出这个函数的曲线\n",
    "x_sample = np.arange(-3, 3.1, 0.1)\n",
    "y_sample = b_target[0] + w_target[0] * x_sample + w_target[1] * x_sample ** 2 + w_target[2] * x_sample ** 3\n",
    "\n",
    "plt.plot(x_sample, y_sample, label='real curve')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "接着我们可以构建数据集，需要 x 和 y，同时是一个三次多项式，所以我们取了 $x,\\ x^2, x^3$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 构建数据 x 和 y\n",
    "# x 是一个如下矩阵 [x, x^2, x^3]\n",
    "# y 是函数的结果 [y]\n",
    "\n",
    "x_train = np.stack([x_sample ** i for i in range(1, 4)], axis=1)\n",
    "x_train = torch.from_numpy(x_train).float() # 转换成 float tensor\n",
    "\n",
    "y_train = torch.from_numpy(y_sample).float().unsqueeze(1) # 转化成 float tensor "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "接着我们可以定义需要优化的参数，就是前面这个函数里面的 $w_i$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# 定义参数和模型\n",
    "w = Variable(torch.randn(3, 1), requires_grad=True)\n",
    "b = Variable(torch.zeros(1), requires_grad=True)\n",
    "\n",
    "# 将 x 和 y 转换成 Variable\n",
    "x_train = Variable(x_train)\n",
    "y_train = Variable(y_train)\n",
    "\n",
    "def multi_linear(x):\n",
    "    return torch.mm(x, w) + b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们可以画出没有更新之前的模型和真实的模型之间的对比"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x115b8cc50>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd4VVXWwOHfIhCqUgQRCQoqFnoJTNARCyKoCDojTXRw\nVNARFHWUM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SMiJzrn/vD9fBfQwDl3\nu8dh+UVELgc+cc7lisgoAOfcII/D8ouInAfkAy+hczVSPA6pyEQkDlgHtEfnk3wN9HTOrfY0MD+I\nSFsgA3jdOdfI63gCISK1gFrOueUicgKwDLgm0v4uIiJARedchoiUAb4ABjjnlhznrX6JqhZ+QbL3\nqQhE7LeZc26ucy7Xd3cJOrQ1Ijnn1jjnAplQ56XWQJpz7kfnXDYwBZ1JHnGcc58DO72OIxicc785\n55b7ft4DrOEokzvDmVMZvrtlfFvI8lZUJXwAERkhIhuBXsCDXscTJDcDc7wOIkbVBjYWun/UWePG\nGyJSF2gOfOVtJP4RkTgRWQFsBT52zoXsc0RcwheReSLy/RG2LgDOuaHOuTrAW0B/b6M9tuN9Ft9r\nhqJDW9/yLtLjK8pnMSbYRKQS8A5w92Fn+BHDOZfnnGuGnsW3FpGQdbdF3CLmx5r5e5i3gA+Ah0IY\nTkCO91lE5CagE9DOhfnFlmL8XSKNzRoPU74+73eAt5xz73odT6Ccc7tE5FOgIxCSC+sR18I/FhGp\nX+huF2CtV7EESkQ6AgOBzs65TK/jiWFfA/VFpJ6IxKNlv5M9jinm+S52vgqscc6N9Toef4lIjYIR\neCJSHh0cELK8FW2jdN4BzkFHhGwAbnfORWRrTETSgLLADt9DSyJ4xNG1wLNADWAXsMI5FzGL4ojI\nlcAzQBwwwTk3wuOQ/CIik4GL0XpXW4CHnHOvehqUn0Tkr8BC4Dv0/zvAf5xzH3gXVfGJSBNgEvpv\nqxQwzTn3aMiOF00J3xhjzNFFVZeOMcaYo7OEb4wxMcISvjHGxAhL+MYYEyMs4RtjTIywhG+MMTHC\nEr4xxsQIS/jGGBMj/h9fRUynBRhSVgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x115846320>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 画出更新之前的模型\n",
    "y_pred = multi_linear(x_train)\n",
    "\n",
    "plt.plot(x_train.data.numpy()[:, 0], y_pred.data.numpy(), label='fitting curve', color='r')\n",
    "plt.plot(x_train.data.numpy()[:, 0], y_sample, label='real curve', color='b')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以发现，这两条曲线之间存在差异，我们计算一下他们之间的误差"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Variable containing:\n",
      " 413.9843\n",
      "[torch.FloatTensor of size 1]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 计算误差，这里的误差和一元的线性模型的误差是相同的，前面已经定义过了 get_loss\n",
    "loss = get_loss(y_pred, y_train)\n",
    "print(loss)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 自动求导\n",
    "loss.backward()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Variable containing:\n",
      " -34.1391\n",
      "-146.6133\n",
      "-215.9148\n",
      "[torch.FloatTensor of size 3x1]\n",
      "\n",
      "Variable containing:\n",
      "-27.0838\n",
      "[torch.FloatTensor of size 1]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# 查看一下 w 和 b 的梯度\n",
    "print(w.grad)\n",
    "print(b.grad)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 更新一下参数\n",
    "w.data = w.data - 0.001 * w.grad.data\n",
    "b.data = b.data - 0.001 * b.grad.data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x1164c6d30>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd4VGX2wPHvoUtRUFCR0FYR6cWAoIuogFgQLCAouui6\nYAEFdREQfzbEBgv2ZVlEsFFVYLHQBF0FREBYpElAkNClY3rm/f1xJhAxIWVmcqecz/PcZ5I7N/ee\nSeDMO+993/OKcw5jjDHRr5jXARhjjCkalvCNMSZGWMI3xpgYYQnfGGNihCV8Y4yJEZbwjTEmRljC\nN8aYGGEJ3xhjYkS+E76IjBeRvSLyY7Z9Z4rIPBHZ5H+slO25ISKSICIbRaRjsAM3xhhTMJLfmbYi\ncjlwDHjXOdfQv+9l4IBz7kURGQxUcs4NEpH6wCSgJXAeMB+40DmXeaprVK5c2dWqVavQL8YYY2LR\nihUrfnXOVcnruBL5PaFz7msRqXXS7i7AFf6vJwKLgEH+/ZOdc6nAzyKSgCb/Jae6Rq1atVi+fHl+\nQzLGGAOIyLb8HBdoH/45zrld/q93A+f4v64GbM92XKJ/nzHGGI8E7aat076hAldiE5E+IrJcRJbv\n27cvWOEYY4w5SaAJf4+IVAXwP+71798BVM92XJx/3x8458Y65+Kdc/FVquTZBWWMMaaQ8t2Hn4tZ\nQC/gRf/jzGz7PxSRUehN2zrAssJcID09ncTERFJSUgIM1RRGmTJliIuLo2TJkl6HYowJUL4TvohM\nQm/QVhaRROApNNFPFZF7gG3ArQDOubUiMhVYB2QAffMaoZObxMREKlSoQK1atRCRwpzCFJJzjv37\n95OYmEjt2rW9DscYE6CCjNK5LZen2uVy/HBgeGGCyi4lJcWSvUdEhLPOOgu7t2JMdIiImbaW7L1j\nv3tjokdEJHxjjIlmr70Gs2eH/jqW8PPhtddeo169evTs2ZNZs2bx4osvAjBjxgzWrVt3/LgJEyaw\nc+fO49//7W9/+93zxhhzsj17YNAg+OST0F8r0FE6M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BpYL9/19IIHnF0E/A6UAU4BKxyznX0Nqr8E5HrgFeA4sB4/1oPEUdEJgFX\noFUZ9wBPOefe9jSoQhKRPwP/Bdag/98BHnfOfeZdVAUnIo2Biei/rWLAVOfcsyG7XjQlfGOMMbmL\nqi4dY4wxubOEb4wxMcISvjHGxAhL+MYYEyMs4RtjTIywhG+MMTHCEr4xxsQIS/jGGBMj/h8fNpTE\n/JAtQgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x115bb9438>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 画出更新一次之后的模型\n",
    "y_pred = multi_linear(x_train)\n",
    "\n",
    "plt.plot(x_train.data.numpy()[:, 0], y_pred.data.numpy(), label='fitting curve', color='r')\n",
    "plt.plot(x_train.data.numpy()[:, 0], y_sample, label='real curve', color='b')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "因为只更新了一次，所以两条曲线之间的差异仍然存在，我们进行 100 次迭代"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch 20, Loss: 73.67840\n",
      "epoch 40, Loss: 17.97097\n",
      "epoch 60, Loss: 4.94101\n",
      "epoch 80, Loss: 1.87171\n",
      "epoch 100, Loss: 1.12812\n"
     ]
    }
   ],
   "source": [
    "# 进行 100 次参数更新\n",
    "for e in range(100):\n",
    "    y_pred = multi_linear(x_train)\n",
    "    loss = get_loss(y_pred, y_train)\n",
    "    \n",
    "    w.grad.data.zero_()\n",
    "    b.grad.data.zero_()\n",
    "    loss.backward()\n",
    "    \n",
    "    # 更新参数\n",
    "    w.data = w.data - 0.001 * w.grad.data\n",
    "    b.data = b.data - 0.001 * b.grad.data\n",
    "    if (e + 1) % 20 == 0:\n",
    "        print('epoch {}, Loss: {:.5f}'.format(e+1, loss.data[0]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以看到更新完成之后 loss 已经非常小了，我们画出更新之后的曲线对比"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x1164e8278>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmcjXX/x/HXZxbr2Ee2wUgS2Zs0FJUldVeksiWpRIpC\nfkIjtLgjpdImqUiLEYWUiFCyhVIMsoUZOynLrGc+vz+uwz0VGXPOzDUz5/N8PK77nHOd61zfzxnd\n7/nO97qu7yWqijHGmPwvyO0CjDHG5AwLfGOMCRAW+MYYEyAs8I0xJkBY4BtjTICwwDfGmABhgW+M\nMQHCAt8YYwJEpgNfRN4VkYMisiHDutIi8rWIbPU+lsrw3lAR2SYiW0Skjb8LN8YYc2Eks1faikhz\n4ATwvqrW8a57HjiqqqNFZAhQSlUHi0ht4GOgMVARWAhcqqqef2sjPDxcIyMjs/xljDEmEK1du/aw\nqpY933Yhmd2hqn4rIpF/W90OuM77fAqwBBjsXT9NVZOBnSKyDSf8V/xbG5GRkaxZsyazJRljjAFE\nZFdmtvN1DL+cqu7zPt8PlPM+rwTsybBdvHedMcYYl/jtoK06Y0MXPBObiPQSkTUisubQoUP+KscY\nY8zf+Br4B0SkAoD38aB3fQJQOcN2Ed51/6CqE1U1SlWjypY97xCUMcaYLMr0GP45zAG6A6O9j7Mz\nrP9IRMbhHLStAazOSgOpqanEx8eTlJTkY6kmKwoVKkRERAShoaFul2KM8VGmA19EPsY5QBsuIvHA\nCJygny4iPYBdQEcAVd0oItOBOCAN6HO+M3TOJT4+nmLFihEZGYmIZGUXJotUlSNHjhAfH0+1atXc\nLscY46MLOUunyzneanmO7UcBo7JSVEZJSUkW9i4REcqUKYMdWzEmf8gTV9pa2LvHfvbG5B95IvCN\nMSZfGz8e5szJ9mYs8DNh/Pjx1KpVi65duzJnzhxGjx4NwKxZs4iLizuz3eTJk9m7d++Z1w888MBf\n3jfGmH/44w8GD0xjwphj2d6Ur2fpBIQ33niDhQsXEhERAUDbtm0BJ/BvueUWateuDTiBX6dOHSpW\nrAjApEmT3Ck4g7S0NEJC7J/ZmNxq76szGZf2CI9EHs32tqyHfx69e/dmx44d3HTTTbz00ktMnjyZ\nvn37snz5cubMmcOgQYNo0KABY8aMYc2aNXTt2pUGDRqQmJjIddddd2aqiLCwMGJiYqhfvz7R0dEc\nOHAAgO3btxMdHU3dunUZNmwYYWFhZ63j/fffp169etSvX59u3boBcO+99zJjxowz25z+7JIlS2jW\nrBlt27aldu3aDBkyhNdff/3MdiNHjuSFF14AYOzYsVx55ZXUq1ePESNG+P8HaIw5N1UmvJKEh2D6\nPlPu/Nv7KG91/fr3h59+8u8+GzSAl18+59sTJkzgq6++YvHixYSHhzN58mQAmjZtStu2bbnlllu4\n8847AZg3bx4vvPACUVFR/9jPyZMniY6OZtSoUTz++OO8/fbbDBs2jH79+tGvXz+6dOnChAkTzlrD\nxo0befbZZ1m+fDnh4eEcPXr+nsC6devYsGED1apV48cff6R///706dMHgOnTpzN//nwWLFjA1q1b\nWb16NapK27Zt+fbbb2nevPl592+M8V3y198y4fCd3NognosvrpLt7VkPP4cUKFCAW265BYArrriC\n3377DYAVK1bQoUMHAO66666zfvabb76hQ4cOhIeHA1C6dOnztte4ceMz5843bNiQgwcPsnfvXtav\nX0+pUqWoXLkyCxYsYMGCBTRs2JBGjRqxefNmtm7d6utXNcZkUuyTGzjERTw6Kvt795DXevj/0hPP\n7UJDQ8+c4hgcHExaWprP+wwJCSE9PR2A9PR0UlJSzrxXtGjRv2zboUMHZsyYwf79++nUqRPgXFg1\ndOhQHnzwQZ9rM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Dm4BK7lZ14dRxwvsy1LtkW27lq8AHEJFR\nIrIH6AoMd7seP7kfmOd2EQGqErAnw+t48mCw5GciEgk0BFa5W0nWiEiwiPwEHAS+VtVs+x55LvBF\nZKGIbDjL0g5AVWNUtTLwIdDX3Wr/3fm+i3ebGJzbRH7oXqXnl5nvYoy/iUgYMBPo/7e/8PMMVfWo\nagOcv+Ibi0i2Dbdlyz1ts5Oqtsrkph8CXwIjsrEcn5zvu4jIvcAtQEvN5QdbLuDfJa9JACpneB3h\nXWdc5h3zngl8qKqful2Pr1T1mIgsBm4EsuXAep7r4f8bEamR4WU7YLNbtfhKRG4EHgfaquopt+sJ\nYD8ANUSkmogUADoDc1yuKeB5D3a+A2xS1XFu15NVIlL29Bl4IlIY5+SAbMut/HaWzkygJs4ZIbuA\n3qqaJ3tjIrINKAgc8a5amYfPOGoPvAqUBY4BP6lqG3eryjwR+Q/wMhAMvKuqo1wuKUtE5GPgOpxZ\nGQ8AI1T1HVeLyiIRuQb4DvgF5//vAE+o6pfuVXXhRKQeMAXnv60gYLqqPp1t7eWnwDfGGHNu+WpI\nxxhjzLlZ4BtjTICwwDfGmABhgW+MMQHCAt8YYwKEBb4xxgQIC3xjjAkQFvjGGBMg/h85QWOUYIeq\neQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x115ad6128>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 画出更新之后的结果\n",
    "y_pred = multi_linear(x_train)\n",
    "\n",
    "plt.plot(x_train.data.numpy()[:, 0], y_pred.data.numpy(), label='fitting curve', color='r')\n",
    "plt.plot(x_train.data.numpy()[:, 0], y_sample, label='real curve', color='b')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以看到，经过 100 次更新之后，可以看到拟合的线和真实的线已经完全重合了"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "**小练习：上面的例子是一个三次的多项式，尝试使用二次的多项式去拟合它，看看最后能做到多好**\n",
    "\n",
    "**提示：参数 `w = torch.randn(2, 1)`，同时重新构建 x 数据集**"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "mx",
   "language": "python",
   "name": "mx"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
